home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2009 December / maximum-cd-2009-12.iso / DiscContents / gimp-2.7.0-i686-setup.exe / {app} / share / gimp / 2.0 / scripts / alien-neon-logo.scm < prev    next >
Encoding:
GIMP Script-Fu Script  |  2009-08-19  |  7.5 KB  |  187 lines

  1. ; GIMP - The GNU Image Manipulation Program
  2. ; Copyright (C) 1995 Spencer Kimball and Peter Mattis
  3. ;
  4. ; alien-neon-logo.scm - creates multiple outlines around the letters
  5. ; Copyright (C) 1999-2000 Raphael Quinet <quinet@gamers.org>
  6. ;
  7. ; This program is free software: you can redistribute it and/or modify
  8. ; it under the terms of the GNU General Public License as published by
  9. ; the Free Software Foundation; either version 3 of the License, or
  10. ; (at your option) any later version.
  11. ;
  12. ; This program is distributed in the hope that it will be useful,
  13. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. ; GNU General Public License for more details.
  16. ;
  17. ; You should have received a copy of the GNU General Public License
  18. ; along with this program.  If not, see <http://www.gnu.org/licenses/>.
  19. ;
  20. ; 1999-12-01 First version.
  21. ; 2000-02-19 Do not discard the layer mask so that it can still be edited.
  22. ; 2000-03-08 Adapted the script to my gimp-edit-fill changes.
  23. ; 2000-04-02 Split the script in two parts: one using text, one using alpha.
  24. ; 2000-05-29 More modifications for "Alpha to Logo" using a separate function.
  25. ;
  26. ; To do: use a channel mask for creating the bands, instead of working in the
  27. ; image.  gimp-invert would then work on one grayscale channel instead of
  28. ; wasting CPU cycles on three identical R, G, B channels.
  29. ;
  30.  
  31. (define (apply-alien-neon-logo-effect img
  32.                                       logo-layer
  33.                                       fg-color
  34.                                       bg-color
  35.                                       band-size
  36.                                       gap-size
  37.                                       num-bands
  38.                                       do-fade)
  39.   (let* (
  40.         (fade-size (- (* (+ band-size gap-size) num-bands) 1))
  41.         (width (car (gimp-drawable-width logo-layer)))
  42.         (height (car (gimp-drawable-height logo-layer)))
  43.         (bg-layer (car (gimp-layer-new img width height RGB-IMAGE "Background" 100 NORMAL-MODE)))
  44.         (bands-layer (car (gimp-layer-new img width height RGBA-IMAGE "Bands" 100 NORMAL-MODE)))
  45.         )
  46.  
  47.     (gimp-context-push)
  48.  
  49.     (script-fu-util-image-resize-from-layer img logo-layer)
  50.     (script-fu-util-image-add-layers img bands-layer bg-layer)
  51.     (gimp-selection-none img)
  52.     (gimp-context-set-background bg-color)
  53.     (gimp-edit-fill bg-layer BACKGROUND-FILL)
  54.     (gimp-context-set-background '(0 0 0))
  55.     (gimp-edit-fill bands-layer BACKGROUND-FILL)
  56.     ; The text layer is never shown: it is only used to create a selection
  57.     (gimp-selection-layer-alpha logo-layer)
  58.     (gimp-context-set-foreground '(255 255 255))
  59.     (gimp-edit-fill bands-layer FOREGROUND-FILL)
  60.  
  61.     ; Create multiple outlines by growing and inverting the selection
  62.     ; The bands are black and white because they will be used as a mask.
  63.     (while (> num-bands 0)
  64.       (gimp-selection-grow img band-size)
  65.       (gimp-invert bands-layer)
  66.       (gimp-selection-grow img gap-size)
  67.       (gimp-invert bands-layer)
  68.       (set! num-bands (- num-bands 1))
  69.     )
  70.  
  71.     ; The fading effect is obtained by masking the image with a gradient.
  72.     ; The gradient is created by filling a bordered selection (white->black).
  73.     (if (= do-fade TRUE)
  74.         (let ((bands-layer-mask (car (gimp-layer-create-mask bands-layer
  75.                                                              ADD-BLACK-MASK))))
  76.           (gimp-layer-add-mask bands-layer bands-layer-mask)
  77.           (gimp-selection-layer-alpha logo-layer)
  78.           (gimp-selection-border img fade-size)
  79.           (gimp-edit-fill bands-layer-mask FOREGROUND-FILL)
  80.           (gimp-layer-remove-mask bands-layer MASK-APPLY)))
  81.  
  82.     ; Transfer the resulting grayscale bands into the layer mask.
  83.     (let ((bands-layer-mask (car (gimp-layer-create-mask bands-layer
  84.                                                          ADD-BLACK-MASK))))
  85.       (gimp-layer-add-mask bands-layer bands-layer-mask)
  86.       (gimp-selection-none img)
  87.       (gimp-edit-copy bands-layer)
  88.       (gimp-floating-sel-anchor (car (gimp-edit-paste bands-layer-mask
  89.                                                       FALSE))))
  90.  
  91.     ; Fill the layer with the foreground color.  The areas that are not
  92.     ; masked become visible.
  93.     (gimp-context-set-foreground fg-color)
  94.     (gimp-edit-fill bands-layer FOREGROUND-FILL)
  95.     ;; (gimp-layer-remove-mask bands-layer MASK-APPLY)
  96.  
  97.     ; Clean up and exit.
  98.     (gimp-drawable-set-visible logo-layer 0)
  99.     (gimp-image-set-active-layer img bands-layer)
  100.     (gimp-displays-flush)
  101.  
  102.     (gimp-context-pop)
  103.   )
  104. )
  105.  
  106.  
  107. (define (script-fu-alien-neon-logo-alpha img
  108.                                          logo-layer
  109.                                          fg-color
  110.                                          bg-color
  111.                                          band-size
  112.                                          gap-size
  113.                                          num-bands
  114.                                          do-fade)
  115.  (begin
  116.     (gimp-image-undo-group-start img)
  117.     (apply-alien-neon-logo-effect img logo-layer fg-color bg-color
  118.                                   band-size gap-size num-bands do-fade)
  119.     (gimp-image-undo-group-end img)
  120.     (gimp-displays-flush)
  121.   )
  122. )
  123.  
  124. (script-fu-register "script-fu-alien-neon-logo-alpha"
  125.     _"Alien _Neon..."
  126.     _"Add psychedelic outlines to the selected region (or alpha)"
  127.     "Raphael Quinet (quinet@gamers.org)"
  128.     "Raphael Quinet"
  129.     "1999-2000"
  130.     "RGBA"
  131.     SF-IMAGE      "Image"             0
  132.     SF-DRAWABLE   "Drawable"          0
  133.     SF-COLOR      _"Glow color"       "green"
  134.     SF-COLOR      _"Background color" "black"
  135.     SF-ADJUSTMENT _"Width of bands"   '(2 1 60 1 10 0 0)
  136.     SF-ADJUSTMENT _"Width of gaps"    '(2 1 60 1 10 0 0)
  137.     SF-ADJUSTMENT _"Number of bands"  '(7 1 100 1 10 0 1)
  138.     SF-TOGGLE     _"Fade away"        TRUE
  139. )
  140.  
  141. (script-fu-menu-register "script-fu-alien-neon-logo-alpha"
  142.                          "<Image>/Filters/Alpha to Logo")
  143.  
  144.  
  145. (define (script-fu-alien-neon-logo text
  146.                                    size
  147.                                    fontname
  148.                                    fg-color
  149.                                    bg-color
  150.                                    band-size
  151.                                    gap-size
  152.                                    num-bands
  153.                                    do-fade)
  154.   (let* (
  155.         (img (car (gimp-image-new 256 256 RGB)))
  156.         (fade-size (- (* (+ band-size gap-size) num-bands) 1))
  157.         (text-layer (car (gimp-text-fontname img -1 0 0 text (+ fade-size 10) TRUE size PIXELS fontname)))
  158.         )
  159.     (gimp-image-undo-disable img)
  160.     (apply-alien-neon-logo-effect img text-layer fg-color bg-color
  161.                                   band-size gap-size num-bands do-fade)
  162.     (gimp-image-undo-enable img)
  163.     (gimp-display-new img)
  164.   )
  165. )
  166.  
  167. (script-fu-register "script-fu-alien-neon-logo"
  168.   _"Alien _Neon..."
  169.   _"Create a logo with psychedelic outlines around the text"
  170.   "Raphael Quinet (quinet@gamers.org)"
  171.   "Raphael Quinet"
  172.   "1999-2000"
  173.   ""
  174.   SF-STRING     _"Text"               "GIMP"
  175.   SF-ADJUSTMENT _"Font size (pixels)" '(150 2 1000 1 10 0 1)
  176.   SF-FONT       _"Font"               "Blippo"
  177.   SF-COLOR      _"Glow color"         "green"
  178.   SF-COLOR      _"Background color"   "black"
  179.   SF-ADJUSTMENT _"Width of bands"     '(2 1 60 1 10 0 0)
  180.   SF-ADJUSTMENT _"Width of gaps"      '(2 1 60 1 10 0 0)
  181.   SF-ADJUSTMENT _"Number of bands"    '(7 1 100 1 10 0 1)
  182.   SF-TOGGLE     _"Fade away" TRUE
  183. )
  184.  
  185. (script-fu-menu-register "script-fu-alien-neon-logo"
  186.                          "<Image>/File/Create/Logos")
  187.